package cn.sieis.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import cn.sieis.tools.Constants;


public class SysInterceptor extends HandlerInterceptorAdapter{
	
	
	private Logger logger=Logger.getLogger(SysInterceptor.class);
	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		// TODO Auto-generated method stub
	
		logger.debug("SysInterceptor preHandle!");
		HttpSession session=request.getSession();
		Object attribute = session.getAttribute(Constants.STUDENT_SESSION);
		if(null==attribute){
			response.sendRedirect(request.getContextPath()+"401.jsp");
			return false;
		}
		
		return true;
	}
}
